/**
 * @author CH_ywx
 * @Date 2023-05-31
 * @Description
 */
package io.xccit;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;

/**
 *@author CH_ywx
 *@Date 2023-05-31
 *@Description Shiro加密相关类
 */
public class ShiroMD5 {
    public static void main(String[] args) {
        //密码明文
        String password = "xccit";
        //md5加密
        Md5Hash md5Hash = new Md5Hash(password);
        System.out.println("Md5加密后:"+md5Hash.toHex());
        //密码明文后拼接字符串再加密
        Md5Hash md5Hash1 = new Md5Hash(password,"2001");
        System.out.println("加盐Md5加密后:"+md5Hash1.toHex());
        //为了保证数据安全,可以多次迭代加密获取更高级别的加密报文
        Md5Hash md5Hash2 = new Md5Hash(password, "2001", 3);//迭代3次加密
        System.out.println("3次迭代Md5加密后:"+md5Hash2.toHex());
        //父类加密
        SimpleHash md5 = new SimpleHash("MD5", password, "2001", 3);
        System.out.println("父类使用MD5加密,带盐,迭代3次:"+md5);
    }
}
